home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / tex / files / !tex / TeXsource / commontex / h / heap < prev    next >
Encoding:
Text File  |  1988-04-08  |  2.2 KB  |  103 lines

  1. /*
  2.  *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
  3.  *    Copying of this file is granted according to the provisions 
  4.  *    specified in the file COPYING which must accompany this file.
  5.  */
  6.  
  7.  
  8. /*
  9.  *        heap.h
  10.  */
  11.  
  12. #define    qi(M)            (M + MIN_QUARTERWORD)
  13. #define    qo(M)            (M - MIN_QUARTERWORD)
  14. #define    hi(M)            (M + MIN_HALFWORD)
  15. #define    ho(M)            (M - MIN_HALFWORD)
  16.  
  17. #ifdef NULL
  18. #undef NULL
  19. #endif
  20. #define    NULL            MIN_HALFWORD
  21.  
  22. global    mword    mem[];
  23. global    ptr        lo_mem_max;
  24. global    ptr        hi_mem_min;
  25.  
  26. global    int        var_used;
  27. global    int        max_var_used;
  28. global    int        dyn_used;
  29.  
  30. #define    link(M)            mem[M].hh.hh1.rh
  31. #define    info(M)            mem[M].hh.hh1.lh
  32.  
  33. global    ptr         avail;
  34. global    ptr        mem_end;
  35.  
  36. ptr get_avail();
  37.  
  38.  
  39. #ifdef    STAT
  40. #define    fast_get_avail(M) \
  41.     {M = avail; \
  42.     if (M == NULL) M = get_avail(); \
  43.     else {avail = link(M); link(M) = NULL; incr(dyn_used);}}
  44. #else
  45. #define    fast_get_avail(M) \
  46.     {M = avail; \
  47.     if (M == NULL) M = get_avail(); \
  48.     else {avail = link(M); link(M) = NULL;}}
  49. #endif
  50.  
  51.  
  52. #ifdef STAT
  53. #define free_avail(M) \
  54.     {link(M) = avail; avail = M; decr(dyn_used);}
  55. #else
  56. #define free_avail(M) \
  57.     {link(M) = avail; avail = M;}
  58. #endif
  59.  
  60. int        flush_list();
  61.  
  62. #define    is_empty(M)            (link(M) == EMPTY_FLAG)
  63. #define    EMPTY_FLAG            MAX_HALFWORD
  64. #define    node_size            info
  65. #define    llink(M)            info(M + 1)
  66. #define    rlink(M)             link(M + 1)
  67.  
  68. global    ptr    rover;
  69.  
  70. ptr        get_node();
  71. int        free_node();
  72.  
  73. global    ptr    temp_ptr;
  74.  
  75. #define    zero_glue         MEM_BOT
  76. #define    fil_glue         (zero_glue + GLUE_SPEC_SIZE)
  77. #define    fill_glue         (fil_glue + GLUE_SPEC_SIZE)
  78. #define    ss_glue          (fill_glue + GLUE_SPEC_SIZE)
  79. #define    fil_neg_glue     (ss_glue + GLUE_SPEC_SIZE)
  80.  
  81. #define    LO_MEM_STAT_MAX    (fil_neg_glue + GLUE_SPEC_SIZE - 1)
  82.  
  83. #define    page_ins_head     (MEM_TOP)
  84. #define    contrib_head      (MEM_TOP - 1)
  85. #define    page_head          (MEM_TOP - 2)
  86. #define    temp_head          (MEM_TOP - 3)
  87. #define    hold_head          (MEM_TOP - 4)
  88. #define    adjust_head        (MEM_TOP - 5)
  89. #define    active          (MEM_TOP - 7)
  90. #define    align_head      (MEM_TOP - 8)
  91. #define    end_span          (MEM_TOP - 9)
  92. #define    lig_trick          (MEM_TOP - 10)
  93. #define    garbage          (MEM_TOP - 10)
  94.  
  95. #define    HI_MEM_STAT_MIN        (MEM_TOP - 10)
  96. #define    HI_MEM_STAT_USAGE    11
  97.  
  98. bool    init_mem();
  99.  
  100. #ifdef INIT
  101. int        sort_avail();
  102. #endif
  103.